﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using jaam_butters.Agents;
using jaam_butters.Ground;

namespace jaam_butters
{
    class GameMode : GameScreen
    {
        KeyboardState keyboardstate;
        Texture2D image;
        Rectangle imagerec;
        //List<DrawableGameComponent> components = new List<DrawableGameComponent>();

        public GameMode (Game game, SpriteBatch spriteBatch, Texture2D image) : base (game, spriteBatch) {
            this.image = image;
            imagerec = new Rectangle (0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
            Jaam tempJaam = new Jaam(game, new Vector2(400,120), spriteBatch);
            components.Add(new GroundGrid(game, new Vector2(340, 60), tempJaam, spriteBatch));
            components.Add(tempJaam);
            components.Add(new Butters(game,spriteBatch));
            components.Add(new Controller(game,tempJaam,spriteBatch));
        }
        /*
        public override void Update(GameTime gameTime) {
            //base.Update(gameTime);
            keyboardstate = Keyboard.GetState();
            if (keyboardstate.IsKeyDown(Keys.Delete))
                game.Exit();
            foreach (DrawableGameComponent i in components) i.Update(gameTime);
        }
        
        public override void Draw(GameTime gameTime) {
            spriteBatch.Draw(image, imagerec, Color.White);
            foreach (DrawableGameComponent i in components) i.Draw(gameTime);
            //base.Draw(gameTime);
        }*/
        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Draw(image, imagerec, Color.White);
            foreach (GameComponent comp in components)
            {
                if (comp is DrawableGameComponent && ((DrawableGameComponent)comp).Visible)
                    ((DrawableGameComponent)comp).Draw(gameTime);
            }
        }


    }
}
